// Waypoint.h: interface for the Waypoint class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_WAYPOINT_H__927234BB_43D7_4D44_BFC7_C9EA1F09A03E__INCLUDED_)
#define AFX_WAYPOINT_H__927234BB_43D7_4D44_BFC7_C9EA1F09A03E__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <stdio.h>
#include <plib/ul.h>
#include <plib/sg.h>
#include <plib/ssg.h>

#define WAYPOINTS_MODEL_NAME "./waypoint.ac"

#define LINE_RED	1.0f,0.0f,0.0f,0.7f
#define LINE_GREEN	0.0f,1.0f,0.0f,0.7f

#define WAYPOINT_LINE_HEIGTH 5.0f
#define MIN_DISTANCE_BETWEEN_WAYPOINTS 10.0f

typedef enum {MAIN, SECONDARY} W_TYPE;

#define ARROW 0
#define LINE  1

struct WPCoord
{
float		n; //north
float		e; //east
float		h; //heigth
ssgTransform* waypoint_t;
ssgTransform* line_t;
};

class Waypoint  
{
public:
	Waypoint(char filename[], float xc, float yc);
	virtual ~Waypoint();

	void create(ssgRoot* root);
	void add(ssgRoot* root, float x, float y, float z);
	void remove(ssgRoot* root, WPCoord* wpc);
	void insert(ssgRoot* root, int bp, int ap, float x, float y, float z);
	WPCoord* get(ssgTransform* t, int what);
	int getPosition(WPCoord* wpc);
	void reposition(ssgRoot* root, WPCoord *wpc, float x, float y, float z);
	void fprint(FILE* f);
	void hideWaypoints();

private:
	ulLinkedList* waypointList;

	float getHeigth(float x, float y, ssgRoot* r);
	void createLine(ssgTransform* t, WPCoord* w1, WPCoord* w2,int color);
	WPCoord* createLERPWaypoint(WPCoord *w1, WPCoord* w2, float d);
	ssgTransform* moveLine(ssgRoot* root, WPCoord* w1, WPCoord* w2);

	float x_correction;
	float y_correction;

	ssgTransform* t;
	ssgEntity*    e;
};

#endif // !defined(AFX_WAYPOINT_H__927234BB_43D7_4D44_BFC7_C9EA1F09A03E__INCLUDED_)
